package com.itheima.StringTest;

//调整字符串的内容并比较：strA经过几次旋转可以到strB
public class StringTest2 {
    public static void main(String[] args) {
        String strA = "abcdea";//bcdea cdeab deabc eabcd abcde
        String strB = "eabcd";
        boolean b = checkStr(strA, strB);
        System.out.println(b);
    }

    public static String rotate(String str) {
        char c = str.charAt(0);
        String substring = str.substring(1);
        substring = substring + c;
        return substring;
    }

    public static boolean checkStr(String strA, String strB) {
        for (int i = 0; i < strA.length(); i++) {
            strA = rotate(strA);
            if (strA.equals(strB)) {
                System.out.println(strA);
                System.out.println(i + 1);
                return true;
            }
        }
        return false;
    }
}

